package com.wanxi.education.controller.back;

import com.wanxi.education.common.CommonResult;
import com.wanxi.education.model.vo.statistic.CertCategoriesVO;
import com.wanxi.education.model.vo.statistic.CoursePopilarityVO;
import com.wanxi.education.model.vo.statistic.InstitutionalRankingVO;
import com.wanxi.education.model.vo.statistic.QuantityOfOrderVO;
import com.wanxi.education.service.StatisticService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @Author: zhe
 * @Date: 2021/9/24 14:05
 * @Description: 后台统计管理
 * @Version: 1.0
 */
@Api(tags = "后台管理统计API")
@RestController
@RequestMapping("/statistics")
public class StatisticController {

    @Autowired
    private StatisticService statisticService;

    @ApiOperation("机构注册人数排名前七API")
    @GetMapping("/institutional-ranking")
    public CommonResult institutionalRanking() {
        Set<InstitutionalRankingVO> institutionalRankingVOSet = statisticService.institutionalRanking();
        return CommonResult.success(institutionalRankingVOSet);
    }

    @ApiOperation("课程热度排名前七API")
    @GetMapping("/course-popularity")
    public CommonResult coursePopularity() {
        Set<CoursePopilarityVO> coursePopilarityVOSet = statisticService.coursePopularity();
        return CommonResult.success(coursePopilarityVOSet);
    }

    @ApiOperation("订单数量API")
    @GetMapping("/quantity-of-order")
    public CommonResult quantityOfOrder() {
        List<QuantityOfOrderVO> quantityOfOrderVOList = statisticService.quantityOfOrder();
        return CommonResult.success(quantityOfOrderVOList);
    }

    @ApiOperation("证书分类数量API")
    @GetMapping("/number-of-cert-categories")
    public CommonResult numberOfCertCategories() {
        Set<CertCategoriesVO> certCategoriesVOSet = statisticService.numberOfCertCategories();
        return CommonResult.success(certCategoriesVOSet);
    }

    /**
     * 测试Session使用
     * @param request
     */
    /*@ApiOperation("数量API")
    @GetMapping("/categories")
    public void categories(HttpServletRequest request) {
        Long loginId = (Long) request.getSession().getAttribute("loginId");
        System.out.println("=================="+loginId);
    }*/


}
